#include <gtest/gtest.h>
#include <stdio.h>
#include <ThreadSafeMaps.hpp>
#include "sds.h"
using namespace thmar;

TEST(TestHashMap, ThreadSafeStringMap)
{
    ThreadSafeStringMap<int> myMap;

    myMap.insert(strdup("apple"), 1);
    myMap.insert(strdup("banana"), 2);
    myMap.insert(strdup("orange"), 3);

    printf("Before erasing banana:\n");
    // 这里可以添加其他操作以验证哈希表的状态

    printf("Size of map: %d\n", myMap.size());

    int value;
    if (myMap.find("banana", value))
    {
        printf("Found banana: %d\n", value);
    }
    else
    {
        printf("Banana not found!\n");
    }

    myMap.erase("banana");

    printf("After erasing banana:\n");
    // 这里可以添加其他操作以验证哈希表的状态
}

TEST(TestHashMap, ThreadSafeIntMap)
{
    ThreadSafeIntMap<char *> myMap;

    myMap.insert(1, "hello");
    myMap.insert(2, "world");
    myMap.insert(3, "jerry");

    printf("Before erasing 2:\n");
    // 这里可以添加其他操作以验证哈希表的状态

    printf("Size of map: %d\n", myMap.size());

    char *value;
    if (myMap.find(2, value))
    {
        printf("Found 2: %s\n", value);
    }
    else
    {
        printf("2 not found!\n");
    }

    myMap.erase(2);

    printf("After erasing 2:\n");
    // 这里可以添加其他操作以验证哈希表的状态
}